package com.xtc.netty.io.bio.http;

import java.io.OutputStream;

public class MyResponse {

    private OutputStream outputStream;

    public MyResponse(OutputStream outputStream) {
        this.outputStream = outputStream;
    }

    public void write(String msg) throws Exception {
        // 用的是http协议，输出也要遵循http协议

        StringBuffer sb = new StringBuffer();
        sb.append("HTTP/1.1 200 OK\n")
                .append("Content-Type: text/html\n")
                .append("\r\n")
                .append(msg);
        outputStream.write(sb.toString().getBytes());
    }
}
